//
//  DoctorHospitalListCell.m
//  Doctor
//
//  Created by 阳光 on 16/10/10.
//  Copyright © 2016年 阳光. All rights reserved.
//

#import "DoctorHospitalListCell.h"

@interface DoctorHospitalListCell ()

@property(nonatomic,strong)UIView *bgView;

// 医院头像
@property(nonatomic,strong)UIImageView *hospitalURL;

// 医院名字
@property(nonatomic,strong)UILabel *hospitalNameLabel;

// 医院所在地
@property(nonatomic,strong)UILabel *hospitalPlaceLabel;

@property(nonatomic,strong)UIImageView *arrowImage;

@end

@implementation DoctorHospitalListCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor=MAIN_BACK_COLOR;
        self.bgView.hidden=NO;
        _hospitalURL.image=[UIImage imageNamed:@"logo"];
        self.hospitalNameLabel.font=Font_Number(16);
        self.hospitalPlaceLabel.font=Font_Number(14);
        self.arrowImage.image=[UIImage imageNamed:@"cell_arrow"];
    }
    return self;
}


-(UIView *)bgView
{
    if (_bgView==nil) {
        _bgView=[UIView new];
        [self.contentView addSubview:_bgView];
        [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(kmargin);
            make.bottom.mas_equalTo(0);
            make.width.mas_equalTo(APPW);
        }];
        _bgView.backgroundColor=WhiteColor;
    }
    return _bgView;
}


// hospitalURL
-(UIImageView *)hospitalURL
{
    if (!_hospitalURL) {
        _hospitalURL=[[UIImageView alloc]init];
        [_bgView addSubview:_hospitalURL];
        [_hospitalURL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin);
            make.top.mas_equalTo(self.bgView.mas_top).offset(kmargin);
            make.width.mas_equalTo(kmargin*10);
            make.bottom.mas_equalTo(-kmargin);
        }];
    }
    return _hospitalURL;
}


// hospitalNameLabel
- (UILabel *)hospitalNameLabel
{
    if (!_hospitalNameLabel) {
        _hospitalNameLabel=[self getLabelWithText:@"生命试管婴儿中心" font:Font_Number(16) textColor:Color333333 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [_bgView addSubview:_hospitalNameLabel];
        [_hospitalNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.hospitalURL.mas_right).offset(kmargin);
            make.top.mas_equalTo(self.hospitalURL.mas_top);
        }];
    }
    return _hospitalNameLabel;
}

// hospitalPlaceLabel
- (UILabel *)hospitalPlaceLabel
{
    if (!_hospitalPlaceLabel) {
        _hospitalPlaceLabel=[self getLabelWithText:@"中国-北京" font:Font_Number(14) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [_bgView addSubview:_hospitalPlaceLabel];
        [_hospitalPlaceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.hospitalURL.mas_right).offset(kmargin);
            make.top.mas_equalTo(self.hospitalNameLabel.mas_bottom).offset(kmargin);
        }];
    }
    return _hospitalPlaceLabel;
}

// arrowImage
-(UIImageView *)arrowImage
{
    if (!_arrowImage) {
        _arrowImage=[[UIImageView alloc]init];
        [_bgView addSubview:_arrowImage];
        [_arrowImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-kmargin);
            make.size.mas_equalTo(CGSizeMake(kmargin*2,kmargin*2));
            make.centerY.mas_equalTo(self.bgView.mas_centerY);
        }];
    }
    return _arrowImage;
}

-(void)setDoctorHospitalListModel:(DoctorHospitalListModel *)doctorHospitalListModel
{
    _doctorHospitalListModel=doctorHospitalListModel;
    
    [_hospitalURL sd_setImageWithURL:[NSURL URLWithString:doctorHospitalListModel.logo_img] placeholderImage:[UIImage imageNamed:@"logo"]];
    
    _hospitalNameLabel.text=doctorHospitalListModel.cn_name;
    
    _hospitalPlaceLabel.text=[NSString stringWithFormat:@"%@-%@",doctorHospitalListModel.country_cn,doctorHospitalListModel.state_cn];
    
}

@end
